﻿using Microsoft.AspNetCore.Mvc;
using zhwy.saas.api.Extensions.Enum;
using zhwy.saas.api.Models;
using zhwy.saas.api.Models.Other.SelectControl;

namespace zhwy.saas.api.Controllers.V1.Other
{
    /// <summary>
    /// 单选多选控件服务
    /// </summary>
    [ApiVersion("1.0")]
    public class SelectControlController : EmptyBaseController
    {

        /// <summary>
        /// 获取枚举列表
        /// </summary>
        /// <param name="enumname">EnumHelper枚举名称</param>
        /// <returns></returns>
        [HttpGet("enum/list")]
        public async Task<ApiResponseModel<List<QueryEnumRes>>> QueryEnum([FromQuery] string enumname)
        {
            var list = new List<QueryEnumRes>();
            switch (enumname)
            {
                case "UsersStatus":
                    list = EnumToListConverter.ToQueryEnumList<EnumHelper.UsersStatus>();
                    break;
                case "UserType":
                    list = EnumToListConverter.ToQueryEnumList<EnumHelper.UserType>();
                    break;
                case "RoleCode":
                    list = EnumToListConverter.ToQueryEnumList<EnumHelper.RoleCode>();
                    break;
            }
            return GetResponseModel<List<QueryEnumRes>>(list.OrderBy(i => i.Id).ToList());
        }

    }
}
